package org.tacademy.and12.mesapp;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MyAdapterViewStock extends ArrayAdapter<MyDataStock>{

	ArrayList<MyDataStock> mList;
	Context mContext;
	TextView lot;
	TextView qty;
	TextView worker;
	TextView workDate;

	public MyAdapterViewStock(Context context, ArrayList<MyDataStock> list) {
		super(context,0, list);
		mList = list;
		mContext = context;
	}
	

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		LinearLayout layoutMyData;
		
		if(convertView == null){
			LayoutInflater inflater = LayoutInflater.from(mContext);
			layoutMyData = (LinearLayout)inflater.inflate(R.layout.fragment_view_stock_sublayout, null);
		}else{
			layoutMyData = (LinearLayout)convertView;
		}
		
		lot = (TextView)layoutMyData.findViewById(R.id.txtLot);
		qty = (TextView)layoutMyData.findViewById(R.id.txtQty);
		worker = (TextView)layoutMyData.findViewById(R.id.txtWorker);
		workDate = (TextView)layoutMyData.findViewById(R.id.txtWorkDate);
		
		MyDataStock currentData = mList.get(position);
		
		lot.setText(currentData.lot);
		qty.setText(currentData.currentQuantity+"");
		worker.setText(currentData.worker);
		workDate.setText(currentData.workDate);		
			
		return (View)layoutMyData;
	}
	
}
